package com.shuqi.common;

import java.io.File;

import com.shuqi.common.utils.Log4an;

public class DownLoadBookUtil {
    public interface DeleteListener {
        public void onFinish();
    }

    /***
     * 删除文件内的所有内容
     * @param path
     */
    public static void deleteFiles(String path) {
        File file = new File(path);
        if (!file.exists()) {
            return;
        }
        if (!file.isDirectory()) {
            return;
        }
        String[] tempList = file.list();
        File temp = null;
        for (int i = 0; i < tempList.length; i++) {
            if (path.endsWith(File.separator)) {
                temp = new File(path + tempList[i]);
            } else {
                temp = new File(path + File.separator + tempList[i]);
            }
            if (temp.isFile()) {
                temp.delete();
            }
            if (temp.isDirectory()) {
                deleteFiles(path + "/" + tempList[i]);// 先删除文件夹里面的文件
                temp.delete();// 再删除空文件夹
            }
        }
        Log4an.i("clearCache", "clear success: " + path);
    }
}
